package com.sx.pipeline.adapter

import android.text.TextUtils
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.sx.pipeline.R
import com.sx.pipeline.repos.http.res.ContactUserVo

class ItemGroupMemberCheckAdapter(var checkList: MutableList<ContactUserVo>) : BaseQuickAdapter<ContactUserVo, BaseViewHolder>
    (R.layout.item_group_member_check, mutableListOf()) {

    override fun convert(holder: BaseViewHolder, item: ContactUserVo) {
        holder.setText(R.id.tv_name, item.userName)
        if(!TextUtils.isEmpty(item.avatar)){
            val ivImage = holder.getView<ImageView>(R.id.image_head)
            Glide.with(context).load(item.avatar).into(ivImage)
        }
        val checkImage = holder.getView<ImageView>(R.id.image_check)
        if(item.hasGroup){
            checkImage.setImageResource(R.drawable.icon_radio_button_unchecked)
        }else{
            if(checkList.contains(item)){
                checkImage.setImageResource(R.drawable.icon_radio_button_checked)
            }else{
                checkImage.setImageResource(R.drawable.icon_radio_button_dischecked)
            }
        }

    }
}